package config

import (
	"encoding/json"
	"log"
	"os"
)

type Configuration struct {
	CITYURL string `json:"city_url"`
}

var configuration *Configuration

func init() {
	dir, _ := os.Getwd()
	log.Println("dir:", dir)
	file, err := os.Open(dir + "/config/config.json")
	if err != nil {
		log.Panicf("open config file err:%s", err)
	}
	defer file.Close()
	decoder := json.NewDecoder(file)

	configuration = &Configuration{}
	err = decoder.Decode(configuration)
	if err != nil {
		log.Panicf("load config err:%s", err)
	}
}

func GetCityUrl() string {
	return configuration.CITYURL
}
